package com.xjzd.pattern.responsibility.logger;

public class Main {

    private static AbstractLogger getChainOfLogger() {
        AbstractLogger consoleLogger = new ConsoleLogger(AbstractLogger.INFO);
        AbstractLogger errorLogger = new ErrorLogger(AbstractLogger.ERROR);
        AbstractLogger fileLogger = new FileLogger(AbstractLogger.DEBUG);

        errorLogger.setNextLogger(fileLogger);
        fileLogger.setNextLogger(consoleLogger);

        return errorLogger;
    }

    public static void main(String[] args) {
        AbstractLogger loggerChain = getChainOfLogger();
        loggerChain.logMessage(AbstractLogger.INFO, "This is an info message");
        System.out.println("------");
        loggerChain.logMessage(AbstractLogger.DEBUG, "This is a debug message");
        System.out.println("------");
        loggerChain.logMessage(AbstractLogger.ERROR, "This is a error message");
    }
}
